#include "datetimewidget.h"
#include "widgets/uclockwidget.h"
#include "widgets/ugaugespeed.h"
#include "widgets/uslider.h"
#include "widgets/uwaterprogress.h"
#include "widgets/uflowlayout.h"
#include "widgets/ucolorpicker.h"
#include "widgets/uspinbox.h"
#include "widgets/ucombobox.h"
#include "widgets/ucommonbutton.h"
#include "widgets/uscorewidget.h"
#include "widgets/ucollapsewidget.h"
#include "widgets/unavigationbar.h"
#include "style/upalette.h"

#include <QBoxLayout>
#include <QComboBox>

DateTimeWidget::DateTimeWidget(QWidget* parent)
    : UWidget(parent)
{
    setBackgroundRole(QPalette::Base);
    setRadius(8);

    UFlowLayout* mainLayout = new UFlowLayout;

    UClockWidget* clockWidget = new UClockWidget(this);
    UGaugeSpeed* gauge = new UGaugeSpeed(this);
    gauge->setRadius(150);

    auto slider = new USlider(Qt::Horizontal, this);
    slider->setFixedSize(260, 40);

    UWaterProgress* progress = new UWaterProgress(this);
    progress->setMinimumSize(200, 200);
    progress->start();

    UColorPicker* picker = new UColorPicker(this);
    UCommonButton* newBuildButton = new UCommonButton("Success Button", this);
    newBuildButton->setIcon(QIcon::fromTheme("utk_home"));
    newBuildButton->setBackgroundRole(UPalette::SuccessBackground);
    newBuildButton->setRadius(8);
    newBuildButton->setRadiuPosition(RadiuPosition::All);
    newBuildButton->setFixedSize(120, 36);

    UCommonButton* newBuildButton1 = new UCommonButton("Warning Button", this);
    newBuildButton1->setBackgroundRole(UPalette::WarningBackground);
    newBuildButton1->setRadius(8);
    newBuildButton1->setRadiuPosition(RadiuPosition::All);
    newBuildButton1->setFixedSize(120, 36);

    UCommonButton* newBuildButton2 = new UCommonButton("Light Button", this);
    newBuildButton2->setButtonFeature(UCommonButtonOption::LightButton);
    newBuildButton2->setBackgroundRole(UPalette::WarningBackground);
    newBuildButton2->setForegroundRole(UPalette::WarningBackground);
    newBuildButton2->setRadius(8);
    newBuildButton2->setRadiuPosition(RadiuPosition::All);
    newBuildButton2->setFixedSize(120, 36);

    UCommonButton* newBuildButton3 = new UCommonButton("Plain Button", this);
    newBuildButton3->setButtonFeature(UCommonButtonOption::PlainButton);
    newBuildButton3->setBackgroundRole(UPalette::Highlight);
    newBuildButton3->setForegroundRole(UPalette::Highlight);
    newBuildButton3->setRadius(8);
    newBuildButton3->setRadiuPosition(RadiuPosition::All);
    newBuildButton3->setFixedSize(120, 36);

    UCollapseWidget* collapseWidget = new UCollapseWidget(this);
    collapseWidget->setFixedWidth(360);
    collapseWidget->setTitleText("UScoreWidget");
    qInfo() << "collapseWidget" << collapseWidget->backgroundRole();

    UScoreWidget* scoreWidget = new UScoreWidget(this);
    scoreWidget->setFixedSize(360, 60);
    scoreWidget->setCount(6);
    scoreWidget->setScoreValue(4.6);

    collapseWidget->addItem(scoreWidget);

    mainLayout->addWidget(clockWidget);
    mainLayout->addWidget(gauge);
    mainLayout->addWidget(slider);
    mainLayout->addWidget(progress);
    mainLayout->addWidget(picker);
    mainLayout->addWidget(collapseWidget);
    auto sinbox = new USpinBox(this);
    mainLayout->addWidget(sinbox);
    auto sinbox1 = new UComboBox(this);
    sinbox1->addItems(QStringList() << "aaa" << "bbb");
    mainLayout->addWidget(sinbox1);
    mainLayout->addWidget(newBuildButton);
    mainLayout->addWidget(newBuildButton1);
    mainLayout->addWidget(newBuildButton2);
    mainLayout->addWidget(newBuildButton3);
    UNavigationButton* navigationButton = new UNavigationButton("UNavigationButton", this);
    navigationButton->setCheckable(true);
    navigationButton->setIcon(QIcon::fromTheme("utk_home"));
    navigationButton->setFixedSize(180, 36);
    mainLayout->addWidget(navigationButton);

    setLayout(mainLayout);

    connect(slider, &QSlider::valueChanged, this, [gauge, progress](int value)
    {
        gauge->setValue(value);
        progress->setValue(value);
    });

    slider->setValue(60);
}

DateTimeWidget::~DateTimeWidget()
{

}
